using System;
using System.Windows;
using System.Windows.Controls.Primitives;

namespace FireStarterModeller.UI.DetailsView.WPF
{
    /// <summary>
    /// Interaction logic for RenameItemPopup.xaml
    /// </summary>
    public partial class NewItemPopup : Popup
    {
        public event EventHandler OKButtonClicked;

        public NewItemPopup()
        {
            InitializeComponent();
        }


        public string NewItemName
        {
            get { return _newItemNameTextBox.Text; }
        }


        private void FireOKButtonClicked()
        {
            if (OKButtonClicked != null) OKButtonClicked(this, new EventArgs());
        }

        public void Init(string itemType)
        {
            _newItemLabel.Content = string.Format("Create new {0} called...", itemType);
        }

        private void Popup_Opened(object sender, EventArgs e)
        {
            _newItemNameTextBox.Focus();
            _newItemNameTextBox.SelectAll();
        }

        private void _okButton_Click(object sender, RoutedEventArgs e)
        {
            FireOKButtonClicked();
        }
    }
}